#ifndef __INTERFEROMETER_H
#define __INTERFEROMETER_H

#include "stm32f10x.h"
#include "OV7725.h"
#include "common.h"
#include "board_GUI_primitives.h"
#include <stdio.h>
#include	<stdlib.h>
#include "systick.h"
#include "FreeRTOS.h"
#include "task.h"


/*
  We should define interferometer data type that we will
  send to PC.
*/
typedef enum
{
    LINE_POSSITION      = 0x00,
    LINE_RIGHT_POSITION = 0x01,
    LINE_LEFT_POSITION  = 0x02,
    LINE_WIDTH          = 0x03
} INTERFEROMETER_DATA_TYPE ;

typedef enum
{
    RISE     = 0x01,
    FALL     = 0x00,
} EDGE ;

typedef struct
{
	EDGE Edge;
	int32_t Position;
} LINE_EDGE;

typedef struct
{
	int32_t RightPosition;
	int32_t LeftPosition;
  int32_t CenterPosition;
  int32_t LineWidth;
  int32_t AbsolutPosition;
  int32_t LineShift;
  int32_t Valid;

} LINES;






#define SEND_PACKET_BUFFER_SIZE 8   /* It is size of data packet. Do not change it. */
#define MAXIMUM_LINES_AMOUNT    5   /* It is amount if white line that we are counting. */
#define ZERO_POSSITION_POINT    150 /* Zero possition of line shifting. */

void send_interferometer_data( INTERFEROMETER_DATA_TYPE data_type, uint32_t data);
void screen_processing(void);
void ordinal_screen(void);
uint32_t line_parameters_calculation(LINE_EDGE *EdgeArray, uint32_t EdgeCounter);
uint32_t center_of_line_parameters_calculation(LINE_EDGE *EdgeArray, uint32_t EdgeCounter);

#endif